package com.ty.service;

import com.ty.dao.InventoryDao;
import com.ty.dto.InventoryChangSource;
import com.ty.entity.InventoryQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ty.entity.Inventory;

import com.ty.service.InventoryService;

import java.util.List;
import java.util.Map;

/**
 * 库存表;(212_inventory)表服务实现类
 * @author : heimi
 * @date : 2025-6-9
 */
@Service
public class InventoryService{
     
    @Autowired
    private InventoryDao inventoryDao;

    @Autowired
    private Map<String,IInvertoryOptionService > optionServiceMap;

    //上下文类
    public void option (InventoryChangSource source){
        //1.从源上获取业务资源
        String code = source.getType().toString();
        //2.运行时 根据业务类型获取对应的策略类
        IInvertoryOptionService iInvertoryOptionService = optionServiceMap.get(code);
        iInvertoryOptionService.option(source);
    }
    public List<Inventory> select(InventoryQuery query) {
        return inventoryDao.select(query);
    }
    
    public Integer insert(Inventory inventory) {
        return inventoryDao.insert(inventory);
    }
    
    public Integer update(Inventory inventory) {
        return inventoryDao.update(inventory);
    }
    
    public Integer delete(Integer id) {
        return inventoryDao.delete(id);
    }

}